<?php
namespace app\common\logic\cast\news;



use app\common\logic\cast\Base;
use app\common\utils\Utils;


/**
 * Created by PhpStorm.
 * User: yangchunfu
 * Date: 2019/12/24
 * Time: 4:36 PM
 * 栏目
 *
 * id,url,title,publishDate,imageUrls
 */

class NewsComic extends Base
{
    protected $apiHref = 'http://api01.idataapi.cn:8000/news/toutiao';
    public function __construct($options= [], $tag = '')
    {
        $options = array_merge([
            'catid' => 'news_comic',
        ], $options);

        parent::__construct($options, $tag);
    }


    /**
     * 获取插入字段
     */
    public function getField($v) {
        $data['news_id'] = isset($v['id']) ? $v['id'] : MD5($v['url']);
        $data['url'] = isset($v['url']) ? $v['url'] : '';
        $data['title'] = isset($v['title']) ? $v['title'] : '';
        if ($v['coverUrl']) {
            $data['imageUrls'] = $v['coverUrl'];
        } else if ($v['imageUrls']) {
            $data['imageUrls'] = $v['imageUrls'];
        } else {
            $data['imageUrls'] = '';
        }

        $data['publishDate'] = isset($v['publishDate']) ? $v['publishDate'] : time();
        $data['viewCount'] = isset($v['viewCount']) ? $v['viewCount'] : 0;
        $data['likeCount'] = isset($v['likeCount']) ? $v['likeCount'] : 0;
        $data['commentCount'] = isset($v['commentCount']) ? $v['commentCount'] : 0;
        return $data;
    }

}